<?php require_once('../Connections/connect.php'); ?>
<?php
$action = $_POST['action'];
$branch_id = $_POST['branch_id'];
$zone_id = $_POST['zone_id'];
if($action == "#zone_div"){?>
		<select style="width:90%;" id="zone" name="zone" onchange="showSelect('#DMA_div');">
    		<option value="" selected="selected" > ---- เลือก Zone ---- </option>
		<?php
            mysql_select_db($database_connect, $connect);
            $query_subType = "SELECT * FROM mwa_area WHERE branch_id='$branch_id' group by zone_id";
            $subType = mysql_query($query_subType, $connect) or die(mysql_error());		
            while($row_q = mysql_fetch_array($subType)){
              $id = $row_q["zone_id"];
              $name = $row_q["zone_name"];
             echo"<option value='$id'>$name</option>";
            };
        ?>      
    	</select> <?php
}else{ ?>
		<select style="width:90%;" id="DMA" name="DMA">
    		<option value="" selected="selected" > ---- เลือก DMA ---- </option>
		<?php
            mysql_select_db($database_connect, $connect);
            $query_subType = "SELECT * FROM mwa_area WHERE branch_id='$branch_id' and zone_id='$zone_id'";
            $subType = mysql_query($query_subType, $connect) or die(mysql_error());		
            while($row_q = mysql_fetch_array($subType)){
              $id = $row_q["DMA_id"];
              $name = $row_q["DMA_name"];
             echo"<option value='$id'>$name</option>";
            };
        ?>      
    	</select> <?php
}
?>
